# Maintainer: Andrew Sun <adsun701@gmail.com>

_realname=libfilezilla
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.21.0
pkgrel=1
pkgdesc="Small and modern C++ library, offering some basic functionality to build high-performing, platform-independent programs (mingw-w64)"
arch=('any')
url="https://lib.filezilla-project.org/"
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-nettle"
         "${MINGW_PACKAGE_PREFIX}-gnutls")
makedepends=("${MINGW_PACKAGE_PREFIX}-gettext")
checkdepends=("${MINGW_PACKAGE_PREFIX}-cppunit")
license=('GPL')
source=("${_realname}-${pkgver}.tar.bz2"::"https://download.filezilla-project.org/${_realname}/${_realname}-${pkgver}.tar.bz2")
sha256sums=('5b8d9f66a244db8309def8b0892949d6a12874d10ba4e21545e5ceab47ec5bf2')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
}

build() {
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}
  
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared

  make
}

check() {
  cd "${srcdir}"/build-${CARCH}
  # LANG needed to fix string_test::test_conversion2
  LANG=en_US.UTF-8 make check || true
}

package() {
  cd "${srcdir}"/build-${CARCH}
  make install DESTDIR="${pkgdir}"
}
